package cn.itcast.exception;

import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SaaSexception implements HandlerExceptionResolver {
    @Override
    public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
        ModelAndView mv=new ModelAndView();
       if (ex instanceof UnauthorizedException){
           mv.setViewName("forward:/unauthorized.jsp");
       }else {

           mv.setViewName("error");

       }
       mv.addObject("errorMsg",ex.getMessage());
        return mv;

    }
}
